//防抖
function debounce(fn,time){
    let timer = null
    return function() {
        if (timer) {
            clearTimeout(timer)
        } else {
            timer=setTimeout(()=>{
                fn()
            },time)
        }
    }
}
//节流
function throttle(fn,time){
    let timer = null
    return function(){
        if (timer) {
            timer=null
        } else {
            timer=setTimeout(()=>{
                fn()
                clearTimeout(timer)
            },time)
        }
    }
}